﻿using System;

namespace Cpu6502.Opcodes
{
    class RTI : Opcode
    {
        public RTI()
        {
            this.CpuCycles = 6;
            this.AddressType = CPU.AddressType.Implied;
        }

        public override void Execute()
        {
            // Pull Processor Flags from Stack
            CPU.Registers.P.Value = CPU.Stack.Pop();
            
            // Pull Return address from stack 
            // Shift it so that it aligns with the PC
            CPU.PC |= (CPU.Stack.Pop() << 8);            
        }
    }
}